package com.example.lenovo.wechat;


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageButton mBtnWeChat;
    private ImageButton mBtnContact;
    private ImageButton mBtnFind;
    private ImageButton mBtnMe;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mBtnWeChat = findViewById(R.id.btn_wechat);
        mBtnContact = findViewById(R.id.btn_contact);
        mBtnFind = findViewById(R.id.btn_find);
        mBtnMe = findViewById(R.id.btn_me);

        mBtnWeChat.setOnClickListener(this);
        mBtnContact.setOnClickListener(this);
        mBtnFind.setOnClickListener(this);
        mBtnMe.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        setTabDefaultColor();
        switch (v.getId()) {
            case R.id.btn_wechat:
                mBtnWeChat.setImageResource(R.mipmap.weixin_pressed);
                break;
            case R.id.btn_contact:
                mBtnContact.setImageResource(R.mipmap.contact_list_pressed);
                break;
            case R.id.btn_find:
                mBtnFind.setImageResource(R.mipmap.find_pressed);
                break;
            case R.id.btn_me:
                mBtnMe.setImageResource(R.mipmap.profile_pressed);
                break;
        }
    }

    private void setTabDefaultColor() {
        mBtnWeChat.setImageResource(R.mipmap.weixin_normal);
        mBtnContact.setImageResource(R.mipmap.contact_list_normal);
        mBtnFind.setImageResource(R.mipmap.find_normal);
        mBtnMe.setImageResource(R.mipmap.profile_normal);
    }
}
